<template>
  <div class="page-container-padding">
    <!-- 日期查询器 -->
    <span>
      <el-date-picker
        v-model="queryDate"
        :clearable="false"
        placeholder="查询日期"
        size="mini"
        style="width: 130px; margin-left: 5px"
      ></el-date-picker>
    </span>
    <span style="margin-left: 5px">
      <el-button
        type="primary"
        size="mini"
        :loading="queryLoading"
        @click="toQuerySpotSeason"
      >
        查询
      </el-button>
    </span>
    <!-- 数据显示 -->
    <div style="margin-top: 10px">
      <el-table border stripe :data="dataList">
        <el-table-column
          prop="variety_name"
          label="品种"
          width="100px"
        ></el-table-column>
        <el-table-column
          prop="close_price"
          label="主力收盘"
          width="110px"
        ></el-table-column>
        <el-table-column
          prop="price"
          label="现货价"
          width="110px"
        ></el-table-column>
        <el-table-column
          prop="zd_value"
          label="现货涨跌"
          width="110px"
        ></el-table-column>
        <el-table-column
          prop="month_avg"
          label="月度均价"
          width="110px"
        ></el-table-column>
        <el-table-column
          prop="quarter_avg"
          label="季度均价"
          width="110px"
        ></el-table-column>
        <el-table-column
          prop="year_avg"
          label="年度均价"
          width="110px"
        ></el-table-column>
        <el-table-column prop="src_note" label="备注"></el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
  import { getSpotSeasonTable } from '@/api/analysisData/spot'
  import { datetimeToStr } from '@/utils/datetimeUtils'
  export default {
    data() {
      return {
        queryDate: new Date(),
        queryLoading: false,
        dataList: [],
      }
    },
    mounted() {
      this.toQuerySpotSeason()
    },
    methods: {
      toQuerySpotSeason() {
        console.log('查询')
        this.queryLoading = true
        getSpotSeasonTable({
          date: datetimeToStr(this.queryDate, true, ''),
        }).then((res) => {
          this.dataList = res.data
          if (res.code !== 200) {
            this.$baseMessage(res.msg, 'error')
          }
          this.queryLoading = false
        })
      },
    },
  }
</script>
<style></style>
